namespace Ross.OA.EntityFramework.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddPOs : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.PODetails",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        order_code = c.String(nullable: false, maxLength: 50),
                        order_line = c.String(nullable: false, maxLength: 8),
                        factory_code = c.String(nullable: false, maxLength: 50),
                        factory_name = c.String(maxLength: 50),
                        fits_code = c.String(nullable: false, maxLength: 50),
                        fits_name = c.String(nullable: false, maxLength: 200),
                        delivery_date = c.DateTime(nullable: false),
                        item_num = c.Single(nullable: false),
                        unit_code = c.String(maxLength: 50),
                        unit_name = c.String(maxLength: 50),
                        logistics_gcode = c.String(maxLength: 50),
                        logistics_gname = c.String(maxLength: 50),
                        inventory_code = c.String(maxLength: 50),
                        inventory_name = c.String(maxLength: 50),
                        buy_item_code = c.String(maxLength: 50),
                        buy_item_type = c.String(maxLength: 50),
                        buy_item_type_name = c.String(maxLength: 50),
                        tax_rate_code = c.String(maxLength: 50),
                        item_is_return = c.Boolean(nullable: false),
                        item_obsolete = c.Int(nullable: false),
                        item_obsolete_name = c.String(maxLength: 50),
                        item_delivered = c.Int(nullable: false),
                        item_delivered_name = c.String(maxLength: 50),
                        item_status = c.Int(nullable: false),
                        item_status_name = c.String(maxLength: 50),
                        item_memo = c.String(maxLength: 500),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.POHeads",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        order_code = c.String(nullable: false, maxLength: 50),
                        company_code = c.String(nullable: false, maxLength: 50),
                        company_name = c.String(maxLength: 50),
                        supplier_code = c.String(maxLength: 50),
                        supplier_name = c.String(maxLength: 50),
                        supplier_contacts = c.String(maxLength: 50),
                        supplier_tele = c.String(maxLength: 50),
                        sap_create_date = c.DateTime(nullable: false),
                        order_type = c.String(maxLength: 50),
                        order_type_name = c.String(maxLength: 50),
                        purchase_gcode = c.String(maxLength: 50),
                        purchase_gname = c.String(maxLength: 50),
                        factory_code_list = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.POPlans",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        company_code = c.String(nullable: false, maxLength: 50),
                        company_name = c.String(maxLength: 50),
                        factory_code = c.String(maxLength: 50),
                        factory_name = c.String(maxLength: 50),
                        supplier_code = c.String(maxLength: 50),
                        supplier_name = c.String(maxLength: 50),
                        fits_code = c.String(nullable: false, maxLength: 50),
                        fits_name = c.String(nullable: false, maxLength: 200),
                        plan_version = c.String(),
                        plan_month = c.DateTime(nullable: false),
                        plan_num = c.Int(nullable: false),
                        diff_prev_num = c.Int(nullable: false),
                        diff_first_num = c.Int(nullable: false),
                        purchase_gcode = c.String(maxLength: 50),
                        purchase_gname = c.String(maxLength: 50),
                        delivery_date = c.DateTime(nullable: false),
                        unit_code = c.String(maxLength: 50),
                        batch_serial = c.String(maxLength: 50),
                        batch_status = c.String(maxLength: 50),
                        first_version = c.Int(nullable: false),
                        first_version_name = c.String(maxLength: 50),
                        Status = c.Int(nullable: false),
                        AcceptTime = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropTable("dbo.POPlans");
            DropTable("dbo.POHeads");
            DropTable("dbo.PODetails");
        }
    }
}
